TARGET = main_mega
MCU_PATH = atm8
DEPEND = $(TARGET).o $(MCU_PATH)/serial.o

CC = avr-gcc
CFLAGS = -Wall -Os -mcall-prologues -mmcu=atmega8
OBJ2HEX = avr-objcopy
AVRDUDE = avrdude
DUDEFLAGS = -c avrispmkII -p m8 -P /dev/ttyUSB0 -e 
FUSEFLAGS = -U lfuse:w:0xe1:m

all: upload

upload: $(TARGET).hex
	$(AVRDUDE) $(DUDEFLAGS) $(FUSEFLAGS) -U flash:w:$<

%.hex: %.obj
	$(OBJ2HEX) -R .eeprom -O ihex $< $@

%.obj: $(DEPEND)
	$(CC) $(CFLAGS) $(DEPEND) -o $@

$(DEPEND):
